<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
                xmlns:lxslt="http://xml.apache.org/xslt"
                xmlns:redirect="http://xml.apache.org/xalan/redirect"
                extension-element-prefixes="redirect">

    <xsl:template match="checktype">
        <xsl:variable name="type" select="@type"/>
        <xsl:variable name="fileCount" select="count(.//file)"/>
        <xsl:variable name="errorCount" select="count(.//error)"/>

        <redirect:write file="{$output.dir}/files/{$type}.html">
            <html>
                <head>
                    <link rel="stylesheet" type="text/css">
                        <xsl:attribute name="href">
                            <xsl:text>../stylesheet.css</xsl:text>
                        </xsl:attribute>
                    </link>
                </head>
                <body>
                    <xsl:call-template name="pageHeader"/>
                    <h3>Type
                        <xsl:value-of select="$type"/>
                        (files:<xsl:value-of select="$fileCount"/>, errors:
                        <xsl:value-of select="$errorCount"/>)
                    </h3>
                    <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
                        <tr>
                            <th>Path</th>
                            <th>Files</th>
                            <th>Errors</th>
                        </tr>
                        <xsl:for-each select="../checktype[@type = $type]">
                            <xsl:apply-templates select="folder" mode="info.folder">
                                <xsl:with-param name="parent-folder" select="''"/>
                                <xsl:with-param name="parent-name" select="''"/>
                            </xsl:apply-templates>
                        </xsl:for-each>
                    </table>
                </body>
            </html>
        </redirect:write>

        <xsl:apply-templates select="folder">
            <xsl:with-param name="parent-folder" select="''"/>
            <xsl:with-param name="parent-name" select="''"/>
        </xsl:apply-templates>
    </xsl:template>

    <xsl:template match="folder" mode="info.folder">
        <xsl:param name="parent-folder"/>
        <xsl:param name="parent-name"/>
        <xsl:variable name="name" select="@name"/>
        <xsl:variable name="fileCount" select="count(../folder[@name=$name]/file)"/>
        <xsl:variable name="errorCount" select="count(../folder[@name=$name]/file/error)"/>


        <xsl:variable name="new-name">
            <xsl:call-template name="from-dos">
                <xsl:with-param name="path" select="@name"/>
            </xsl:call-template>
        </xsl:variable>

        <xsl:if test="$fileCount > 0">
            <tr>
                <xsl:call-template name="alternated-row"/>
                <td nowrap="nowrap">
                    <a target="mainFrame">
                        <xsl:attribute name="href">
                            <xsl:value-of select="concat($parent-folder,$new-name)"/>
                            <xsl:text>summary.html</xsl:text>
                        </xsl:attribute>
                        <xsl:value-of select="concat($parent-name, @name)"/>
                    </a>
                </td>
                <td>
                    <xsl:value-of select="$fileCount"/>
                </td>
                <td>
                    <xsl:value-of select="$errorCount"/>
                </td>
            </tr>
        </xsl:if>

        <xsl:apply-templates select="./folder" mode="info.folder">
            <xsl:sort select="@name"/>
            <xsl:with-param name="parent-folder" select="concat($parent-folder,$new-name)"/>
            <xsl:with-param name="parent-name" select="concat($parent-name, @name)"/>
        </xsl:apply-templates>
    </xsl:template>


</xsl:stylesheet>